export default {
    clearUserInfo (state) {
        state.token = null;
        state.educationInfo = {};
        state.userInfo = {};
        state.isLogin = false;
    },
    overRideValue (state, payload) {
        state[payload.state] = Object.assign(
            {},
            state[payload.state],
            payload.value
        );
    },
    clickeDbtn (state, payload) {
        const keyword = Object.keys(state.tempEducationInfo);
        if (keyword.length) {
            // 用户单击了保存按钮，要判断是否将tempEducationInfode的信息覆盖到eduInfo,并且持久化存储数据库
            // 如果tempEducationInfo的键名和eduInfo
            state.educationInfo = Object.assign(
                {},
                state.educationInfo,
                state.tempEducationInfo
            );
            payload.success.call(payload.that);
        } else {
            payload.error.call(payload.that);
        }
    },
    saveUpdatePicture (state, payload) {
        for (const keys of payload) {
            const obj = {};
            for (const index in keys) {
                obj[index] = keys[index];
            }
            state.tempOrderPicture.push(obj);
        }
    },
    resetStatus (state, payload) {
        if (typeof payload.status !== 'boolean') {
            throw Error(`I wish type of status value is Boolean, but got ${typeof payload.status}`);
        }
        state[payload.state] = payload.status;
    },
    simpleAssignment (state, payload) {
    // 这个mutation只针对简单属性赋值
        state[payload.state] = payload.value;
    }
};
